/*********************************************************
          File Name:13.8.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Wed 16 Sep 2015 09:09:36 PM CST
**********************************************************/

#include <string>

class HasPtr
{
        public:
                HasPtr(const std::string &s = std::string()):
                        ps(new std::string(s)), i(0) {}
                HasPtr(const HasPtr &hp);
                HasPtr &operator=(const HasPtr &hp)
                {
                        // ignore memory leak
                        ps = new std::string(*hp.ps);

                        i = hp.i;

                        return *this;
                }
        private:
                std::string *ps;
                int i;
};

HasPtr::HasPtr(const HasPtr &hp)
{
        ps = new std::string(*hp.ps);   // `hp.ps` is `string *`
        i = hp.i;
}

